FROM debian:buster-slim as build

RUN printf 'deb http://mirrors.bfsu.edu.cn/debian buster main contrib non-free\n' > /etc/apt/sources.list && \
    printf 'APT::Install-Recommends "false";\nAPT::Install-Suggests "false";\n' > /etc/apt/apt.conf.d/no-recommends-suggests && \
    apt-get -o "Acquire::https::Verify-Peer=false" update && \
    apt-get -o "Acquire::https::Verify-Peer=false" install -y ca-certificates && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update
RUN apt-get install -y fonts-wqy-microhei

FROM alpine:latest

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.bfsu.edu.cn/g' /etc/apk/repositories
RUN apk update

RUN apk add curl
RUN apk add openjdk8-jre

COPY --from=build /usr/share/fonts/truetype/wqy/wqy-microhei.ttc /usr/share/fonts/wqy/wqy-microhei.ttc
COPY --from=build /etc/fonts/conf.avail/65-wqy-microhei.conf /etc/fonts/conf.avail/65-wqy-microhei.conf
COPY --from=build /etc/fonts/conf.d/65-wqy-microhei.conf /etc/fonts/conf.d/65-wqy-microhei.conf
RUN fc-cache -s

COPY /deploy/cache/usr /usr
COPY /src/astah-ui /usr/bin/astah-ui

CMD ["/usr/bin/astah-ui"]
